# Contributor: Holger Jaekel <holger.jaekel@gmx.de>
# Maintainer: Holger Jaekel <holger.jaekel@gmx.de>
pkgname=cfitsio
pkgver=3.49
pkgrel=0
pkgdesc="A library reading and writing data files in Flexible Image Transport System data format"
url="https://heasarc.gsfc.nasa.gov/fitsio/"
arch="all"
license="custom"
makedepends="
	bzip2-dev
	curl-dev
	gfortran
	"
subpackages="
	$pkgname-static
	$pkgname-dev
	"
source="https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-$pkgver.tar.gz"

build() {
	./configure \
		--prefix=/usr \
		--with-bzip2 \
		--enable-reentrant \
		--enable-sse2 \
		--enable-ssse3 \
		--enable-hera
	make shared
	make utils
}

package() {
	make DESTDIR="$pkgdir" install
	mkdir -p "$pkgdir"/usr/share/licenses/cfitsio/
	cp License.txt "$pkgdir"/usr/share/licenses/cfitsio/

	# delete test/demo programs
	rm "$pkgdir"/usr/bin/testprog
	rm "$pkgdir"/usr/bin/cookbook

	# avoid conflicts with smem
	rm "$pkgdir"/usr/bin/smem
}

check() {
	LD_LIBRARY_PATH=. ./testprog > testprog.lis
	[[ -z $(diff testprog.lis testprog.out) ]]
	[[ -z $(cmp testprog.fit testprog.std) ]]
}
sha512sums="9836a4af3bbbfed1ea1b4c70b9d500ac485d7c3d8131eb8a25ee6ef6662f46ba52b5161c45c709ed9a601ff0e9ec36daa5650eaaf4f2cc7d6f4bb5640f10da15  cfitsio-3.49.tar.gz"
